//统一管理咱们项目用户相关的接口
import request from '@/api/index'


//项目用户相关的请求地址
//axios的请求的泛型已经重写<any占位,类型>，直接写<类型>
//登录接口
export const reqLoginAPI = (data: loginFormData) =>
  request.post<loginResponseData>('/api/user/login', data)
//获取用户信息

export const reqUserInfoAPI = () =>
  request.get<userInfoReponseData>('/api/user/info')

/**
* @name 获取菜单权限和按钮权限
*/
import { allAsyncRoutes, } from '@/routers/modules/dynamicRouter'
import { staticRoutes, anyRoutes } from '@/routers/modules/staticRouter'
export const getAuthApi = () => {
  request.get<userInfoReponseData>('/api/user/info')
  return new Promise<any>((resolve, reject) => {
    resolve({
      code: 200,
      data: {
        authButtonList: [],
        authMenuList: allAsyncRoutes
      },
      message: '请求成功'
    })
  })
};


//退出登录
export const reqLogoutAPI = () => request.post<{}>('/api/user/logout')


//定义用户相关数据的ts类型 
//用户登录接口携带参数的ts类型
interface loginFormData {
  username: string
  password: string
}

//定义登录接口返回数据类型
interface loginResponseData {
  token: string
}

//定义获取用户信息返回数据类型
export interface userInfoReponseData {
  username: string
  avatar: string
}